home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.002.BusyBox / busybox.p / uevent.p < prev    next >
Encoding:
Text File  |  1990-06-19  |  3.9 KB  |  167 lines  |  [TEXT/MPS ]

  1. {**********************************************************************
  2. {*
  3. {* BusyBox uEvent -- Version 3.0  (interface)
  4. {*
  5. {* Copyright (c)
  6. {* Apple Computer, Inc.  1986-1989
  7. {* All Rights Reserved.
  8. {*
  9. {* This file contains the interface to the code which implements the 
  10. {* main event loop used by the busybox program.
  11. {*
  12. {**********************************************************************}
  13.  
  14. UNIT uEvent;
  15.  
  16. INTERFACE
  17.  
  18. USES
  19.        types,
  20.        GSOS,
  21.        memory,
  22.        locator,
  23.        quickdraw,
  24.        events,
  25.        resources,
  26.        controls,
  27.        windows,
  28.        lineedit,
  29.        dialogs,
  30.        menus,
  31.        stdfile,
  32.        IntMath,
  33.        Fonts,
  34.        Desk,
  35.  
  36.        uGlobals,
  37.        uUtils,
  38.        uWindow,
  39.        uMenu;
  40.  
  41.  
  42.  
  43. procedure MainEvent;   {Main event handling loop which repeats until Quit}
  44.  
  45. IMPLEMENTATION
  46.  
  47. {$R-}
  48.  
  49. var
  50.     LastWindow   : GrafPortPtr;         { This private global is used in CheckFrontW.
  51.                                         { to prevent extra work when the windows
  52.                                         { have not changed.  It is initialized
  53.                                         { at the beginning of MainEvent. }
  54.  
  55.  
  56.  
  57.  
  58. {*******************************************************************}
  59. {
  60. { DoControls
  61. {
  62. { This procedure is called when an inControl message is returned
  63. { by TaskMaster.
  64. {
  65. { When this routine gets control, the ID of the control that was
  66. { hit is in TaskDATA4.  The control handle is in TaskData2 and
  67. { the part code is in taskData 3.
  68. {
  69. {*******************************************************************}
  70. procedure DoControls;
  71. var
  72.     TheID : integer;
  73. begin
  74.     TheID := Event.wmTaskData4;
  75.     if (ButButtonsID <= TheID) and (TheID <= Prog6ID) then
  76.         OpenThisWindow(TheID);
  77. end;
  78.  
  79.  
  80.  
  81. {*******************************************************************}
  82. {
  83. { CheckFrontW
  84. {
  85. { This routine checks the front window to see if any changes need
  86. { to be made to the menu items.
  87. {
  88. { We do this so that the edit items are only active when a desk
  89. { accessory is active.
  90. {
  91. {*******************************************************************}
  92. procedure CheckFrontW;
  93.  
  94. var 
  95.     theWindow    : GrafPortPtr;
  96.  
  97. begin   {of CheckFrontW}
  98.     { Get the front window into local storage.}
  99.     theWindow := FrontWindow;
  100.     
  101.     { If the LastWindow is this window, we are all set. }
  102.     if theWindow = lastWindow then Exit(CheckFrontW);
  103.     
  104.     { If there are no windows, everything should be disabled }
  105.     if theWindow = nil then 
  106.         begin
  107.             SetMenuFlag ($0080,EditMenuID);
  108.             DrawMenuBar;
  109.         end 
  110.     else
  111.         begin
  112.             { Otherwise we look at the window and see what to do. }
  113.             if GetSysWFlag (theWindow) <> false then 
  114.                 begin   {Set up for da windows}
  115.                     SetMenuFlag ($FF7F,EditMenuID);
  116.                     DrawMenuBar;
  117.                 end
  118.             else
  119.                 begin   {Set up for our windows}
  120.                     SetMenuFlag ($0080,EditMenuID);
  121.                     DrawMenuBar;
  122.                 end;
  123.         end;
  124.     
  125.     { Remember this for next time. }
  126.     lastWindow := theWindow;
  127. end;    {of CheckFrontW}
  128.  
  129.  
  130.  
  131.  
  132.  
  133. {************************************************************************
  134. {
  135. { MainEvent
  136. {
  137. { This is the main part of the program.  The program cycles in this
  138. { loop until the user choose select.
  139. {
  140. {************************************************************************}
  141. procedure MainEvent;
  142.  
  143.  
  144. var 
  145.     code : integer;
  146.  
  147.  
  148. begin   {of MainEvent}
  149.    Event.wmTaskMask := $001FFFFF;       { Allow TaskMaster to do everything. }
  150.    Done             := false;           { Done flag will be set by Quit item. }
  151.    LastWindow       := NIL;             { Init this for CheckFrontW. }
  152.  
  153.    repeat
  154.        CheckFrontW;
  155.        code := TaskMaster ($FFFF,Event);
  156.        case code of
  157.            wInGoAway    : DoCloseTop;
  158.            wInSpecial,
  159.            wInMenuBar   : DoMenu;
  160.            wInControl   : DoControls;
  161.        end;
  162.    until Done;
  163. end;    {of MainEvent}
  164.  
  165.  
  166. END.
  167.